package fr.emse.tatiana.replayable.analysis;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;


import fr.emse.tatiana.display.BadDisplayFile;

public abstract class AbstractAnalysisInput implements IEditorInput {

	protected static int ID = 0;
	
	protected IAnalysis model;
	protected IFile file;
	protected IProject p;
	
	public AbstractAnalysisInput(IProject p) {
		this.p=p;
	}
	
	public AbstractAnalysisInput(IFile file) {
		this.file=file;
	}
	
	public abstract IAnalysis getModel() throws BadDisplayFile;

	public boolean exists() {
		return file.exists();
	}

	public ImageDescriptor getImageDescriptor() {
		return null;
	}

	public String getName() {
		try {
			return getModel().getName();
		} catch (BadDisplayFile e) {
			return "Untitled";
		}
	}

	public IPersistableElement getPersistable() {
		// TODO z later when persistence is implemented
		return null;
	}

	public String getToolTipText() {
		return getName();
	}

	public Object getAdapter(Class adapter) {
		return null;
	}
	
	public IFile getFile() {
		return this.file;
	}
	
	public void setFile(IFile file) {
		this.file=file;
	}

}
